package com.jishi.gouwuche.conf;

import cn.hutool.json.JSONUtil;

import com.jishi.gouwuche.common.Result;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;

import java.io.IOException;

public class MyAuthFilter extends FormAuthenticationFilter {
    @Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(JSONUtil.toJsonStr(Result.error("未授权")));
        response.getWriter().flush();
        return false;
    }
}
